<html>
<head>
    <meta charset="utf-8"/>
<meta name="description" content=""/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>

<title>ADB工具简单学习（一） | 絷缘的博客</title>

<link rel="shortcut icon" href="https://zydnc.gitee.io/favicon.ico?v=1732378515642">

<link href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://zydnc.gitee.io/styles/main.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.5.0/dist/css/bootstrap.min.css">

<script src="https://cdn.jsdelivr.net/npm/@highlightjs/cdn-assets/highlight.min.js"></script>
<script src="https://cdn.bootcss.com/highlight.js/9.15.10/languages/dockerfile.min.js"></script>
<script src="https://cdn.bootcss.com/highlight.js/9.15.10/languages/dart.min.js"></script>

<script src="https://cdn.jsdelivr.net/npm/moment@2.27.0/moment.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.5.0/dist/js/bootstrap.min.js"></script>
<!-- DEMO JS -->
<!--<script src="media/scripts/index.js"></script>-->



    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.12.0/dist/katex.css">
 <script src='//unpkg.com/valine/dist/Valine.min.js'></script>
</head>
<body>
<div class="main gt-bg-theme-color-first">
    <nav class="navbar navbar-expand-lg">
    <div class="navbar-brand">
        <img class="user-avatar" src="/images/avatar.png" alt="头像">
        <div class="site-name gt-c-content-color-first">
            絷缘的博客
        </div>
    </div>
    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent"
            aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
        <i class="fas fa-bars gt-c-content-color-first" style="font-size: 18px"></i>
    </button>
    <div class="collapse navbar-collapse" id="navbarSupportedContent">
        <div class="navbar-nav mr-auto" style="text-align: center">
            
                <div class="nav-item">
                    
                        <a href="/" class="menu gt-a-link">
                            首页
                        </a>
                    
                </div>
            
                <div class="nav-item">
                    
                        <a href="/archives" class="menu gt-a-link">
                            归档
                        </a>
                    
                </div>
            
                <div class="nav-item">
                    
                        <a href="/tags" class="menu gt-a-link">
                            标签
                        </a>
                    
                </div>
            
                <div class="nav-item">
                    
                        <a href="/about" class="menu gt-a-link">
                            关于
                        </a>
                    
                </div>
            
                <div class="nav-item">
                    
                        <a href="/friends" class="menu gt-a-link">
                            友链
                        </a>
                    
                </div>
            
        </div>
        <div style="text-align: center">
            <form id="gridea-search-form" style="position: relative" data-update="1732378515642" action="/search/index.html">
                <input class="search-input" autocomplete="off" spellcheck="false" name="q" placeholder="搜索文章" />
                <i class="fas fa-search gt-c-content-color-first" style="position: absolute; top: 9px; left: 10px;"></i>
            </form>
        </div>
    </div>
</nav>

    <div class="post-container">
        <div class="post-detail gt-bg-theme-color-second">
            <article class="gt-post-content">
                <h2 class="post-title">
                    ADB工具简单学习（一）
                </h2>
                <div class="post-info">
                    <time class="post-time gt-c-content-color-first">
                        · 2023-05-14 ·
                    </time>
                    
                        <a href="https://zydnc.gitee.io/CkL42eVrY/" class="post-tags">
                            # ADB
                        </a>
                    
                        <a href="https://zydnc.gitee.io/2V4hmsWjwD/" class="post-tags">
                            # 调试
                        </a>
                    
                </div>
                <div class="post-content">
                    <h1 id="adb工具">ADB工具</h1>
<h3 id="1-获取设备序列号">1. 获取设备序列号</h3>
<blockquote>
<p><code>adb get-serialno</code></p>
</blockquote>
<h3 id="2-获取设备电量">2. 获取设备电量</h3>
<blockquote>
<p><code>adb shell dumpsys battery</code></p>
<p><code>adb shell dumpsys battery set usb 1</code> 设置为USB充电状态</p>
</blockquote>
<pre><code class="language-shell">Current Battery Service state:
  AC powered: false
  USB powered: false
  Wireless powered: false
  Max charging current: 0
  Max charging voltage: 0
  Charge counter: 3433133
  status: 3
  health: 2
  present: true
  level: 90
  scale: 100
  voltage: 4232
  temperature: 337
  technology: Li-ion
</code></pre>
<h3 id="3-获取设备内存">3. 获取设备内存</h3>
<blockquote>
<p><code>adb shell cat /proc/meminfo</code></p>
<p><code>adb shell procrank</code></p>
<p><code>adb shell dumpsys meminfo</code></p>
</blockquote>
<pre><code class="language-shell">Total RAM: 5,981,832K (status normal)
 Free RAM: 4,121,672K (  123,068K cached pss + 3,998,604K available)
 Used RAM: 1,610,051K (1,372,495K used pss +   237,556K kernel)
 Lost RAM:    44,661K
     ZRAM:        20K physical used for       224K in swap (1,048,572K total swap)
   Tuning: 256 (large 512), oom   322,560K, restore limit   107,520K (high-end-gfx)
</code></pre>
<h3 id="4-获取设备容量">4. 获取设备容量</h3>
<blockquote>
<p><code>adb shell df /data/media</code></p>
<p><code>adb shell df /data </code></p>
</blockquote>
<h3 id="5-获取设备列表">5. 获取设备列表</h3>
<blockquote>
<p><code>adb devices</code></p>
</blockquote>
<h3 id="6-获取设备状态">6. 获取设备状态</h3>
<blockquote>
<p><code>adb get-state</code></p>
<p><code>device</code>：设备正常连接</p>
<p><code>offline</code>：连接异常，设备无响应</p>
<p><code>unknown</code>：没有连接的设备</p>
</blockquote>
<h3 id="7-安装应用">7. 安装应用</h3>
<blockquote>
<p><code>adb install packageName</code></p>
<p>执行结果：</p>
<ul>
<li>
<p><code>Success</code>：安装成功</p>
</li>
<li>
<p><code>INSTALL_FAILED_ALREADY_EXISTS</code>：安装失败</p>
</li>
<li>
<p><code>INSTALL_FAILED_SIGNATURE_ERROR</code>：签名不一致</p>
</li>
<li>
<p><code>INSTALL_FAILED_INSUFFICIENT_STORAGE</code>：存储空间不足</p>
</li>
</ul>
<p><code>adb install -r packageName</code>：重新安装</p>
</blockquote>
<h3 id="8-卸载应用">8. 卸载应用</h3>
<blockquote>
<p><code>adb uninstall</code></p>
</blockquote>
<h3 id="9-文件互传">9. 文件互传</h3>
<blockquote>
<p>将本地文件传到设备上</p>
<p><code>adb push 本地文件全路径 /sdcard/</code></p>
<p>将设备上的文件移动到本地</p>
<p><code>adb pull /sdcard/demo.txt 本地路径</code></p>
</blockquote>
<h3 id="10-获取设备上所有应用信息">10. 获取设备上所有应用信息</h3>
<blockquote>
<p><code>adb shell pm list package</code></p>
<p><code>-s</code>：列出所有系统应用包名</p>
<p><code>-f</code>：列出所有应用包名，apk名及存放位置</p>
</blockquote>
<h3 id="11-设备重启">11. 设备重启</h3>
<blockquote>
<p><code>adb reboot</code></p>
</blockquote>
<h3 id="12-查看android系统版本">12. 查看Android系统版本</h3>
<blockquote>
<p><code>adb shell getprop ro.build.version.release</code></p>
</blockquote>
<h3 id="13-获取cpu信息">13. 获取CPU信息</h3>
<blockquote>
<p><code>adb shell cat /proc/cpuinfo</code></p>
</blockquote>
<h3 id="14-设备关机">14. 设备关机</h3>
<blockquote>
<p><code>adb shell reboot -p</code></p>
</blockquote>
<h3 id="15-屏幕点击事件">15. 屏幕点击事件</h3>
<blockquote>
<p><code>adb shell input tap x轴 y轴</code></p>
</blockquote>
<h3 id="16-屏幕滑动事件">16. 屏幕滑动事件</h3>
<blockquote>
<p><code>adb shell input swipe x轴start y轴start x轴end y轴end</code></p>
</blockquote>
<h3 id="17-屏幕按键事件">17. 屏幕按键事件</h3>
<blockquote>
<p><code>adb shell input keyevent 按键事件</code></p>
</blockquote>
<h3 id="18-获取设备型号">18. 获取设备型号</h3>
<blockquote>
<p><code>adb -d shell getprop ro.product.model</code></p>
</blockquote>
<blockquote>
<p>原文作者：絷缘<br>
作者邮箱：zhiyuanworkemail@163.com<br>
原文地址：<a href="https://zhiyuandnc.github.io/gipeLHNM2/">https://zhiyuandnc.github.io/gipeLHNM2/</a><br>
版权声明：本文为博主原创文章，转载请注明原文链接作者信息</p>
</blockquote>

                </div>
            </article>
        </div>

        
            <div class="next-post">
                <div class="next gt-c-content-color-first">下一篇</div>
                <a href="https://zydnc.gitee.io/RGEfzFph6/" class="post-title gt-a-link">
                    CRON表达式学习
                </a>
            </div>
        

        

        

        

        <div class="site-footer gt-c-content-color-first">
    <div class="slogan gt-c-content-color-first">事实不以人的意志为转移</div>
    <div class="social-container">
        
            
                <a href="#" target="_blank">
                    <i class="fab fa-github gt-c-content-color-first"></i>
                </a>
            
        
            
                <a href="#" target="_blank">
                    <i class="fab fa-telegram gt-c-content-color-first"></i>
                </a>
            
        
            
                <a href="#" target="_blank">
                    <i class="fab fa-qq gt-c-content-color-first"></i>
                </a>
            
        
            
                <a href="#" target="_blank">
                    <i class="fab fa-bilibili gt-c-content-color-first"></i>
                </a>
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
    </div>
    <div class="footer-info">
        Copyright&ensp;&copy;&ensp;絷缘的博客<br/><a href="https://beian.miit.gov.cn/" target="_blank">晋ICP备20001723号-1</a>
    </div>
    <div>
        Theme by <a href="https://imhanjie.com/" target="_blank">imhanjie</a>, Powered by <a
                href="https://github.com/getgridea/gridea" target="_blank">Gridea | <a href="https://zydnc.gitee.io/atom.xml" target="_blank">RSS</a></a>
    </div>
</div>

<script>
  hljs.initHighlightingOnLoad()
</script>

    </div>
</div>
</body>
</html>
